const { Sequelize } = require('sequelize')
const { database, username, password, ...restConfig } = require('../config')
const sequelize = new Sequelize(database, username, password, restConfig)

// const Realtime = require('./Realtime')(sequelize) // 测试是否连接成功
// // Realtime.sync({ force: true })

// exports.Realtime = Realtime

const History = require('./History')(sequelize)
// History.sync({ force: true })
exports.History = History

const Comment = require('./Comment')(sequelize)
// Comment.sync({ force: true })
exports.Comment = Comment
;(async () => {
  try {
    await sequelize.authenticate()
    console.log('Connection has been established successfully.')
  } catch (error) {
    console.error('Unable to connect to the database:', error)
  }
})()

exports.sequelize = sequelize
